﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MvcApplication
{
    public static class CreateResponseReslut
    {
        /// <summary>
        /// 返回统一的报文体.
        /// </summary>
        /// <param name="data">返回的对象.</param>
        /// <returns></returns>
        public static ResponseReslut CreateSuccess(this object data)
        {
            return new ResponseReslut {code=200,data= data,msg= "ok" };
        }

        /// <summary>
        /// 返回统一的报文体.
        /// </summary>
        /// <param name="data">返回的对象.</param>
        /// <returns></returns>
        public static ResponseReslut CreateSuccess()
        {
            return new ResponseReslut { code = 200, data = new object(), msg = "ok" };
        }


        /// <summary>
        /// 返回统一的报文体.
        /// </summary>
        /// <param name="data">返回的对象.</param>
        /// <returns></returns>
        public static ResponseReslutPage CreateSuccessPage(this object data,int total)
        {
            return new ResponseReslutPage { code = 200, data = data, msg = "ok" ,total=total};
        }

        /// <summary>
        /// 返回统一的报文体.
        /// </summary>
        /// <param name="data">返回的对象.</param>
        /// <returns></returns>
        public static ResponseReslut CreateFail(this string msg,int _code=500)
        {
            return new ResponseReslut { code = _code, data = new object(), msg = msg };
        }

    }
}
